import sys

from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QPushButton, QMessageBox, QFrame

'''
载人图片类 QPixmap("./img/a1.jpg")
    lblpic = QLabel(self)
    lblpic.setPixmap(QPixmap("./img/a1.jpg"))
    lblpic.resize(300, 210)
    self.lblpic.setScaledContents(True)  # 控制图片自适应控件 缩放大小

载人并配置时钟控件
    timer1 = QTimer(self) # QTimer 可自定义槽方法timer_Timer
    timer1.timeout.connect(self.timer_Timer) 
    timer1.start(1000)
'''


class MyClass(QMainWindow):
    def __init__(self):
        super().__init__()
        self.n = 1
        self.initUI()

    def initUI(self):
        self.setWindowTitle('刘金玉编程教程')
        self.setWindowIcon(QIcon('./img/msn.ico'))
        self.setGeometry(800, 370, 400, 300)

        self.pm = QPixmap("./img/a"+str(self.n)+".jpg")
        self.lblpic = QLabel(self)
        self.lblpic.setPixmap(self.pm)
        self.lblpic.resize(300, 210)
        self.lblpic.move(50, 25)
        self.lblpic.setScaledContents(True)  # 控制图片自适应缩放大小

        timer1 = QTimer(self)  # QTimer 可自定义槽方法timer_Timer, QTimebase 对应 TimerEvent()
        timer1.timeout.connect(self.timer_Timer)  # timeout 超时间隔执行都槽方法
        timer1.start(1000)  # 启动，指定超时间隔ms

        self.show()

    def timer_Timer(self):
        self.n += 1
        if self.n > 4:
            self.n = 1
        self.pm = QPixmap("./img/a" + str(self.n) + ".jpg")
        self.lblpic.setPixmap(self.pm)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    myf = MyClass()
    app.exec_()
